package org.example.myleet.p430;

import org.example.myleet.Utils.Assert;
import org.example.myleet.Utils.Node;
import org.example.myleet.Utils.Parser;

import java.util.Objects;

public class Main {
    public static void main(String[] args) {
        Solution solution = new Solution();
        Assert.isTrue("[1,2,3,7,8,11,12,9,10,4,5,6]".equals(serializeNode(solution.flatten(Parser.parseComplexNodeRoot(new Integer[]{1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12})))));
        Assert.isTrue("[1,3,2]".equals(serializeNode(solution.flatten(Parser.parseComplexNodeRoot(new Integer[]{1,2,null,3})))));
        Assert.isTrue("[]".equals(serializeNode(solution.flatten(Parser.parseComplexNodeRoot(new Integer[]{})))));
    }
    private static String serializeNode(Node head) {
        if (Objects.isNull(head)) {
            return "[]";
        }
        return "[" + head.toString() + "]";
    }
}
